package day13;

import java.io.File;
import java.io.IOException;

public class FileDemo {
    public static void main(String[] args) {
      //  creatFile("file3.txt");
        creatFile("/Users/jinnian/Desktop/fil3.txt");
      //  creatFolder("/Users/jinnian/Desktop/dde");
      //  creatFolder("/Users/jinnian/Desktop/ddw/re/we");
        //creatFile();
        File f=new File("/Users/jinnian/Desktop/ddw/re/yui");
        System.out.println(f.isDirectory());
    }

    private static void creatFolder(String pathname) {

        File file=new File(pathname);
        if(!file.exists()){ //没有创建



           if(file.mkdirs()){       //创建


               System.out.println(file+"muluchuangjianchenggong");


           }else {
               System.out.println("muluchuangjianshibai");
           }


            }
        else{
            System.out.println("cunzaile");
        }
    }

    private static void creatFile(String pathname) {
        File file=new File(pathname);
        if(!file.exists()) {
            try {
                if (file.createNewFile()) {
                    System.out.println("chenggong");
                     System.out.println("mulu"+file.getName());
                       System.out.println(file.getAbsolutePath());
                } else {
                    System.out.println("shibai");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }else
        {
            System.out.println("wenjaincinzai");
        }


    }
}
